package com.wg.net.operations;

import com.wg.core.io.BigEndianBinaryReader;
import com.wg.core.io.IBinaryReader;
import com.wg.core.io.IBinaryReadable;
import com.wg.core.thread.fiber.IFiber;
import com.wg.net.operations.base.OperationRequest;
import com.wg.net.protocols.IProtocol;
import com.wg.net.session.ISession;

public class InitRequest implements IBinaryReadable {
    private String appId;
    private ISession peer;
    private IFiber requestFiber;
    private IProtocol protocol;

    public InitRequest(IProtocol protocol, OperationRequest operationRequest) {
        this.protocol = protocol;
        readBytes(new BigEndianBinaryReader(operationRequest.getBuffer()));
    }

    public ISession getPeer() {
        return peer;
    }

    public void setPeer(ISession peer) {
        this.peer = peer;
    }

    public IFiber getRequestFiber() {
        return requestFiber;
    }

    public void setRequestFiber(IFiber fiber) {
        this.requestFiber = fiber;
    }

    public int getLocalPort() {
        return peer.getLocalPort();
    }

    public String getLocalIp() {
        return peer.getLocalIp();
    }

    public int getRemotePort() {
        return peer.getRemotePort();
    }

    public String getRemoteIp() {
        return peer.getRemoteIp();
    }

    public IProtocol getProtocol() {
        return protocol;
    }

    public String getAppId() {
        return appId;
    }

    @Override
    public void readBytes(IBinaryReader reader) {
        appId = reader.readString();
    }
}
